#!/bin/bash

#为目录
if [ -d "$1" ]; then
  for file in $(ls $1); do
    chmod 777 "$file"
  done
#为文件
#改错$1 -> $file
elif [ -f "$1" ]; then
  chmod 777 "$1"
#不传参，则直接chmod 777当前目录
elif [ -z "$1" ]; then
  dir=$(pwd)
  for file in $(ls $dir); do
    chmod 777 "$file"
  done
else
  echo '文件或目录不存在'
  exit
fi
